#include		<iostream>
#include	 	"HandleInformations.hpp"
#ifndef _WIN32
 #include		"ServerUnix.h"
#else
 #include		"ServerWin.h"
#endif
#include		"StockMessage.hpp"
#include		"Connection.hpp"
#include		"common.h"
#include		"Parser.hpp"
#include		<string>
#include		<utility>
#include		<fstream>

using namespace	std;

extern StockMessage<std::pair<std::string, int> >		inputList;
extern StockMessage<std::pair<std::string, int> >		outputList;

void							*HandleInformations(void *useless)
{
	const pair<string, int>		*msg = NULL;
	std::pair<string, int>		*myResponse = new std::pair<std::string, int>;
	Parser				*myParser = new Parser();

	while (1)
	{
		msg = inputList.getMessage();
		if (msg != NULL)
		{
			myParser->Parse(msg->second, msg->first);
			myResponse->second = msg->second;
			outputList.addMessage(myResponse);

			msg = NULL;
		}
		common::Sleep(1);
	}
	return (NULL);
}
